<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="../../../../../WEB-INF/myTag.tld" prefix="my"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>今日值班</title>
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/animate.min.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/style.min.css?v=4.0.0" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
	
</head>

<body class="gray-bg">
    <!-- 分页 -->
	<form id="pagerForm" method="post" action="listOnduty.do">
		<input type="hidden" name="currentPage" id="currentPage" value="1" />
		<input type="hidden" name="name" value="${ondutydataStore.name}" />
		<input type="hidden" name="leader" value="${ondutydataStore.leader}" />
		<input type="hidden" name="timestart" value="${ondutydataStore.timestart}" />
		<input type="hidden" name="timeend" value="${ondutydataStore.timeend}" />
	</form>
    
    <div class="wrapper wrapper-content animated fadeInRight">
    	<div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>今日值班列表</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                    
                    	<!-- 搜索区 -->
                    	<div class="m-b-sm">
                    	<form id="ondutyList" name="ondutyList" action="listOnduty.do" method="post">

                    	<div class="m-b-sm">
                    	
                    	<div class="col-md-2">
                    		<div class="input-group">
                    			<span class="input-group-addon">值班人:</span>
								<input type="text" class="form-control" name="name" id="name" value="${ondutydataStore.name}"/>
							</div>
						</div>
						
						<div class="col-md-2">
							<div class="input-group">
                    			<span class="input-group-addon">带班人:</span>
								<input type="text" class="form-control" name="leader" id="leader" value="${ondutydataStore.leader}"/>
							</div>
						</div>
						
						<div class="col-md-4" id="data_5">
                            <div class="input-daterange input-group" id="datepicker">
                            	<span class="input-group-addon input-title">值班时间:</span>
                                <input type="text" class="form-control" name="timestart" value="${ondutydataStore.timestart}" />
                                <span class="input-group-addon">至</span>
                                <input type="text" class="form-control" name="timeend" value="${ondutydataStore.timeend}" />
                            </div>
                        </div>
                    	</div>
                    	
                    	<button type="submit" id="search" class="btn btn-info" ><i class="fa fa-search"></i>&nbsp;&nbsp;搜索</button>
                    	</form>
                    	</div>
                    	
                    	<div class="m-b-sm">
                    		<button type="button" class="btn btn-success btn-sm" onclick="addOnduty();"><i class="fa fa-plus-circle"></i>&nbsp;&nbsp;添加</button>
                    	</div>

						<!-- 列表区 -->
						<div class="m-b-sm">
							<table id="table" data-toggle="table" data-striped="true" >
								<thead>
									<tr>
										<th data-visible="false">id</th>
										<th data-width="3%" data-align="center">序号</th>
										<th data-width="15%">带班人名称</th>
										<th data-width="15%">带班人电话</th>
										<th data-width="12%">值班人名称</th>
										<th data-width="12%">值班室电话</th>
										<th data-width="15%">值班人电话</th>
										<th data-width="15%">值班时间</th>
										<th data-width="13%" data-align="center">操作</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${pageInfo.resultList}" var="item" varStatus="i">
										<tr>
											<td>${item.ondutyId}</td>
											<td>${i.index + 1}</td>
											<td>${item.leader}</td>
											<td>${item.leaderPhone}</td>
											<td>${item.name}</td>
											<td>${item.dutyphone}</td>
											<td>${item.telephone}</td>
											<td><my:DateSubString date="${item.time}" subNum="16"/></td>
											<td>
											    <button type="button" class="btn btn-info btn-xs" onclick="editOnduty('${item.ondutyId}');">修改</button>
												<button type="button" class="btn btn-danger btn-xs" onclick="delOnduty('${item.ondutyId}');">删除</button>
												
											</td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>

						<jsp:include page="../../../common/turnPage.jsp" />
					</div>
                </div>
            </div>
            
        </div>

		<!-- <div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						
					</div>
				</div>
			</div>
		</div> -->

	</div>
    
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/jquery.min.js?v=2.1.4"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/content.min.js?v=1.0.0"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/toastr/toastr.min.js"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/layer/layer.js"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/bootstrap-table/bootstrap-table.js"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    
    <script type="text/javascript">
    
    var basePath = '<%=request.getContextPath()%>';
    
    toastr.options = {
  		  "closeButton": true,
  		  "debug": false,
  		  "progressBar": true,
  		  "positionClass": "toast-top-left",
  		  "showDuration": "400",
  		  "hideDuration": "1000",
  		  "timeOut": "3000",
  		  "extendedTimeOut": "1000",
  		  "showEasing": "swing",
  		  "hideEasing": "linear",
  		  "showMethod": "fadeIn",
  		  "hideMethod": "fadeOut"
  		}
    
    //初始化日期控件
    $("#data_5 .input-daterange").datepicker({
        keyboardNavigation: !1,
        forceParse: !1,
        autoclose: !0
    });
    
    //添加
    var addOnduty = function(){
    	
    	layer.open({
    		  type: 2,
    		  title: '添加今日值班',
    		  shadeClose: true,
    		  shade: 0.3,
    		  area: ['800px', '450px'],
    		  content: basePath + '/bgPortGlutOnduty/addOndutyLogin.do' //iframe的url
    		});
    	
    }
    
    //editOnduty修改今日值班记录
    var editOnduty = function(mId){
    	layer.open({
  		  type: 2,
  		  title: '修改今日值班记录',
  		  shadeClose: true,
  		  shade: 0.3,
  		  area: ['800px', '450px'],
  		  content: basePath + '/bgPortGlutOnduty/editOndutyLogin.do?ondutyId='+mId //iframe的url
  		});
    }
    
    
    /******删除值班记录******/
	var delOnduty = function(mId){
		
		layer.confirm('确定要删除该记录吗？', {
			  btn: ['确定','取消'] //按钮
			}, function(index){
			  
				layer.close(index);
				
				$.ajax({
					type : "POST",
					url : basePath + "/bgPortGlutOnduty/delOnduty.do?ondutyId="+mId,
					data : {"ids" : mId},
					dataType : "json",
					success : function(msg) { 
						if (msg.errCode == '1') {
							layerCallBack('1');
						}else{
							toastr.error(msg.errMsg, "提示");
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
						toastr.error("系统出错！", "提示");
					},
					beforeSend : function(XMLHttpRequest){
						layer.load(0, {
							  shade: [0.3,'#ccc'] //0.1透明度的白色背景
							});
					},
					complete : function(XMLHttpRequest, textStatus){
						layer.closeAll();
					}
				});
				
			}, function(){
			  
			});
		
	}
    
    //操作成功
    var layerCallBack = function(status){
    	if(status == '1'){
    		layer.closeAll();
    		toastr.success("操作成功！", "提示");
    		
    		setTimeout(function(){
    			location.reload();
    		}, 1000);
    		
    	}else if(status == '2'){
    		layer.closeAll();
    		toastr.success("操作成功！", "提示");
    	}
    }
    
    </script>
    
</body>

</html>